package cn.tedu.egmvc4.base.exception;

import cn.tedu.egmvc4.base.response.JsonResult;
import cn.tedu.egmvc4.base.response.StatusCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
  /*  @ExceptionHandler
    public JsonResult doHandleIllegalArgumentException(IllegalArgumentException ex){
        String date = ex.getMessage();
        log.error("doHandleIllegalArgumentException:"+date);
        return new JsonResult(StatusCode.OPERATION_FAILED,date);
    }
    @ExceptionHandler
    public JsonResult doHandleRuntimeException(RuntimeException ex){
        String date = ex.getMessage();
        log.error("doHandleRuntimeException:"+date);
        return new JsonResult(StatusCode.OPERATION_FAILED,date);
    }*/
    @ExceptionHandler
    public JsonResult doHandleThrowable(Throwable ex){
        String date = ex.getMessage();
        log.error("doHandleThrowable:"+date);
        return new JsonResult(StatusCode.THROWABLE_ERROR,date);
    }
}
